//
//  TelevisionControl.m
//  iPhoneControlApplication
//
//  Created by Elliot Chapple on 11/04/2009.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import "TelevisionControl.h"


@implementation TelevisionControl

//Synth Objects
@synthesize		channelPlus;
@synthesize		channelMinus;
@synthesize		volumePlus;
@synthesize		volumeMinus;
@synthesize		button0;
@synthesize		button1;
@synthesize		button2;
@synthesize		button3;
@synthesize		button4;
@synthesize		button5;
@synthesize		button6;
@synthesize		button7;
@synthesize		button8;
@synthesize		button9;
@synthesize		selectButton;
@synthesize		leftArrow;
@synthesize		upArrow;
@synthesize		rightArrow;
@synthesize		downArrow;
@synthesize		channelLabel;

//Methods

-(IBAction)channelUpButtonPress
{
	NSString *currentValue = channelLabel.text;
	int newValue = [currentValue intValue];
	newValue = newValue + 1;
	NSString *updatedvalue = [[NSString alloc] initWithFormat:@"%d", newValue];
	channelLabel.text = updatedvalue;
	//NSString *channelTitle = channelLabel.text;
	NSString *newText = [[NSString alloc] initWithFormat:@"Now Viewing Channel:  %@.", updatedvalue];
	UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"TV Programme Changed" message:newText delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil];
	[alert show];
	[alert release];
	[newText release];
}



-(IBAction)channelDownButtonPress
{
	NSString *currentValue = channelLabel.text;
	int newValue = [currentValue intValue];
	newValue = newValue - 1;
	NSString *updatedvalue = [[NSString alloc] initWithFormat:@"%d", newValue];
	channelLabel.text = updatedvalue;
	//NSString *channelTitle = channelLabel.text;
	NSString *newText = [[NSString alloc] initWithFormat:@"Now Viewing Channel:  %@.", updatedvalue];
	UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"TV Programme Changed" message:newText delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil];
	[alert show];
	[alert release];
	[newText release];
}


-(IBAction)volumeUpButtonPress
{
	UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Volume Increased" message:nil delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil];
	[alert show];
	[alert release];
}


-(IBAction)volumeDownButtonPress
{
	UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Volume Decreased" message:nil delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil];
	[alert show];
	[alert release];
}


-(IBAction)numberButtonPress:(id)sender
{
	NSString *title = [sender titleForState:UIControlStateNormal];
	NSString *newText = [[NSString alloc] initWithFormat:@"The %@ has been selected", title];
	UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Button Selected" message:newText delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil];
	[alert show];
	[alert release];
	[newText release];
}


-(IBAction)navigationButtonPress:(id)sender
{
	NSString *title = [sender titleForState:UIControlStateNormal];
	NSString *newText = [[NSString alloc] initWithFormat:@"The %@ has been selected", title];
	UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Button Selected" message:newText delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil];
	[alert show];
	[alert release];
[newText release];}


-(IBAction)selectButtonPress
{
	UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Item Selected" message:nil delegate:self cancelButtonTitle:@"Okay" otherButtonTitles:nil];
	[alert show];
	[alert release];
}













//Apple Code as in previous
/*
// The designated initializer. Override to perform setup that is required before the view is loaded.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        // Custom initialization
    }
    return self;
}
*/

/*
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView {
}
*/

/*
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    [super viewDidLoad];
}
*/

/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning]; // Releases the view if it doesn't have a superview
    // Release anything that's not essential, such as cached data
}


- (void)dealloc {
    [super dealloc];
}


@end
